//using Newtonsoft.Json;

//namespace MultiAgentsClient.Tools;

//public class GitOperationToolProvider
//{
//    public static async Task<bool> AddCommentToMergeRequest(string gitLabBaseUrl, string projectId, int mergeRequestId, string commentBody, string privateToken)
//    {
//        string gitLabUrl = $"{gitLabBaseUrl}/api/v4/projects/{projectId}/merge_requests/{mergeRequestId}/notes";
//        using HttpClient httpClient = new();
//        httpClient.DefaultRequestHeaders.Add("PRIVATE-TOKEN", privateToken);

//        StringContent postData = new($"{{\"body\": \"{commentBody}\"}}", System.Text.Encoding.UTF8, "application/json");
//        HttpResponseMessage response = await httpClient.PostAsync(gitLabUrl, postData);

//        return response.IsSuccessStatusCode;
//    }

//    public static async Task<string> GetMergeRequestChanges(string gitLabBaseUrl, string projectId, int mergeRequestId, string privateToken)
//    {
//        string gitLabUrl = $"{gitLabBaseUrl}/api/v4/projects/{projectId}/merge_requests/{mergeRequestId}/changes";
//        using HttpClient httpClient = new();
//        httpClient.DefaultRequestHeaders.Add("PRIVATE-TOKEN", privateToken);

//        HttpResponseMessage response = await httpClient.GetAsync(gitLabUrl);

//        if (response.IsSuccessStatusCode)
//        {
//            string changesJson = await response.Content.ReadAsStringAsync();
//            return changesJson;
//        }
//        else
//        {
//            return $"Failed to get merge request changes. Status code: {response.StatusCode}";
//        }
//    }

//    public static async Task<int> GetLatestMergeRequestId(string gitLabBaseUrl, string projectId, string privateToken)
//    {
//        string gitLabUrl = $"{gitLabBaseUrl}/api/v4/projects/{projectId}/merge_requests?state=opened&order_by=updated_at&sort=desc";
//        using HttpClient httpClient = new();
//        httpClient.DefaultRequestHeaders.Add("PRIVATE-TOKEN", privateToken);

//        HttpResponseMessage response = await httpClient.GetAsync(gitLabUrl);

//        if (response.IsSuccessStatusCode)
//        {
//            string jsonResponse = await response.Content.ReadAsStringAsync();
//            var mergeRequests = JsonConvert.DeserializeObject<List<dynamic>>(jsonResponse);

//            var latestMergeRequest = mergeRequests?.FirstOrDefault();
//            if (latestMergeRequest != null)
//            {
//                return (int)latestMergeRequest.iid;
//            }
//        }

//        return -1;
//    }
//}
